﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DoAn_BumTruong_DesignPattern
{
     class ModuleProxy:Abstract
    {
         ModuleController mdctrl;
         public List<Module> ListAll()
         {
             if (mdctrl == null)
             {
                 mdctrl = new ModuleController();
             }
             return mdctrl.SelectAll();
         }
         public List<Module> Paging(string page,out int howManyPage)
         {
             if (mdctrl == null)
             {
                 mdctrl = new ModuleController();
             }
             return mdctrl.Paging(page,out howManyPage);
         } 
        public override bool Add(object o)
        {
            throw new NotImplementedException();
        }

        public override bool Delete(object o)
        {
            throw new NotImplementedException();
        }

        public override bool Update(object o)
        {
            throw new NotImplementedException();
        }

        //Update Active
        public override bool UpdateActive(int id, bool state)
        {
            try
            {
                if (mdctrl == null)
                    mdctrl = new ModuleController();
                return mdctrl.UpdateActive(id, state);
            }
            catch (Exception)
            {
                throw;
            }
        }

         //Update Position
        public override bool UpdatePosition(int id, int pos)
        {
            try
            {
                if (mdctrl == null)
                    mdctrl = new ModuleController();
                return mdctrl.UpdatePosition(id, pos);
            }
            catch (Exception)
            {
                return false;
            }
        }

        //
        public override bool UpdateOrderNo(int id, int order)
        {
            throw new NotImplementedException();
        }

        public override bool UpdateMenuType(int id, int type)
        {
            throw new NotImplementedException();
        }
    }
}